<?php
/**
 * Vebba PHP Framework & Website Builder
 *
 * <pre>
 * File containing functionalities for managing cookies
 * </pre>
 *
 * @package   classes.core.static
 * @version   0.7.1511 alpha
 * @since     2012
 * @author    Paul Dinh
 * @copyright Devyra Internacionalnaya
 */
 
/**
 * Class for processing cookies
 * @author  Paul Dinh
 * @version 0.7.1511 alpha
 */
class cookie {

  /*
   * All properties
   */
  private static $Cookies = array();

  /**
   * Default instance level constructor
   */
  public function __construct() {
    //
  }
  
  /**
   * Some initialisation
   */
  public static function initialise() {
    //
  }
  
  /**
   * Set a cookie value
   *
   * @param string $Name  The name of cookie
   * @param string $Value The value of cookie
   */
  public static function set($Name,$Value) {
    $Module_Path     = helper::get_script_path();
    $Cookie_Lifetime = system::$Configs["cookie"]["lifetime"];
    
    setcookie($Name,$Value,time()+$Cookie_Lifetime,"/$Module_Path");
    self::$Cookies[$Name] = $Value;
  }
  
  /**
   * Get a cookie value
   *
   * @param  string $name The name of cookie
   * @return string       The value of cookie or 'null' if no such cookie
   */
  public static function get($Name) {
    if (isset(self::$Cookies[$Name]))
      return self::$Cookies[$Name];
    else
    if (isset($_COOKIE[$Name])) 
      return $_COOKIE[$Name];
    else
      return null;
  }
}

//END-OF-FILE
